<?php
/* @var $this ShopCityController */
/* @var $model ShopCity */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'shop-city-_shopcity-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // See class documentation of CActiveForm for details on this,
        // you need to use the performAjaxValidation()-method described there.
        'enableAjaxValidation' => false,
    ));
    ?>




    <div class="form_left">
        <?php echo $form->labelEx($model, 'cityName'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'cityName'); ?>
        <?php echo $form->error($model, 'cityName'); ?>
    </div>
    <div class="clear"></div>

    <div class="form_left">
        <?php echo $form->labelEx($model, 'flag'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->dropDownList($model, 'flag', array('1' => 'Hiễn thị')); ?>
        <?php echo $form->error($model, 'flag'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">.</div>
    <div class="form_right">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/media/css/demo_table_jui.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/examples_support/themes/smoothness/jquery-ui-1.8.4.custom.css" />
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        oTable = $('#example').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers"
        });
    });
</script>
<?php
     $session = new CHttpSession;
            $session->open();
          
    $sql = 'SELECT * FROM `shop_city` where flag = 1 and shopid ='.$session['user_salesmart'][3];

$dbCommand = Yii::app()->db->createCommand($sql);
$results = $dbCommand->queryAll();

if (!empty($results)) {
    ?>
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
        <thead>
            <tr>
                <th>Tên tỉnh/thành</th>
                             
                <th>Xóa</th>
            </tr>
        </thead>
        <tbody>
    <?php
    //include 'encode_decode.php';

    Yii::import('application.controllers.home.encode_decode');
    $md = new encode_decode();
    if (!empty($results)) {
        foreach ($results as $item) {
            $ma = $md->encrypt($item['id']);
            ?>
                    <tr class="gradeA">
                        <td>

            <?php echo '<a style="text-decoration: none" href="' . Yii::app()->request->baseUrl . '/xem-city-shop/' . $ma . '">' . $item['cityName'] . '</a>' ?>
                        </td>

                        

                        <td class="center">
            <?php echo '<a style="text-decoration: none;color: red" href="' . Yii::app()->request->baseUrl . '/xoa-city-shop/' . $ma . '">' . 'Xóa</a>' ?>

                        </td>
                    </tr>
            <?php
        }
    }
    ?>
        </tbody>
    </table>
    <?php
} else {
    echo 'Bạn chưa có tỉnh/thành nào!';
}
